package com.easy.controller;

import com.easy.bean.Harvest;
import com.easy.service.HarvestService;
import com.easy.util.Page;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("harvest")
public class HarvestController {
    @Autowired
    HarvestService harvestService;
    @PostMapping
    public Result add(@RequestBody Harvest harvest){
        Object obj = harvestService.add(harvest);
        return Result.success(obj);
    }
    @PutMapping
    public Result edit(@RequestBody Harvest harvest){
        Object obj = harvestService.edit(harvest);
        return Result.success(obj);
    }
    @DeleteMapping("{harvest_id}")
    public Result del(@PathVariable("harvest_id") Integer id){
        Object obj = harvestService.del(id);
        return Result.success(obj);
    }
    @GetMapping("{harvest_id}")
    public Result one(@PathVariable("harvest_id") Integer id){
        Object obj = harvestService.one(id);
        return Result.success(obj);
    }

    @GetMapping("all")
    public Result all(Harvest harvest){
        Object obj = harvestService.all(harvest);
        return Result.success(obj);
    }
    @GetMapping("page")
    public Result page(Page page, Harvest harvest){
        harvestService.page(page,harvest);
        return Result.success(page);
    }
}
